<template>
  <div  class='relative'>
  	<!-- 搜索栏 -->
  	<a-row>
		<a-col :span="12"  class='mb20'>
				<a-input  placeholder="请输入"  class='w200'  v-model='search.keyWord'   />  <!-- allowClear  input长度会设置成100%  -->
				<a-button type="primary"  @click='pageInit()'>搜索</a-button>
				<!-- <a-icon type="loading-3-quarters"  spin  :style="{ fontSize: '16px', color: '#1890ff' }"/>  -->
		</a-col>
 
	</a-row>
	
	<!-- 表格切换 -->
	 
    <a-spin   :indicator="indicator"  tip="正在加载中..."  :spinning='spinning'  :delay="delayTime">
		<a-table :columns="columns" :dataSource="data"  :rowKey="record => record.code" :pagination="pagination"  @change="handleTableChange"> 
			<span slot="assetsType"  slot-scope="text, record">{{text | propertyType}}</span>
			<span slot="createTime"  slot-scope="text, record">{{text | formatDate}}</span>

			<span slot="status"  slot-scope="text, record">{{text | auditStatus}}</span>
			<span slot="action" slot-scope="text, record">
			  <router-link  :to='{path:"/customer/fininacing/audit",query:{code:record.code}}'  class='color-blue'  v-if='record.status == 0'> 审核 <a-divider type="vertical" /> </router-link>
			 
				<a-popconfirm title="确认删除当前数据？" @confirm="confirmDel(record.code)"   okText="确认" cancelText="取消">
				    <a href="javascript:;"  class='color-red'>删除</a>
				</a-popconfirm>
			</span>
		</a-table>
	</a-spin>
  </div>
</template>

<script>
import { list_customer_financing,del_cus_property }  from  '@/api/customer/index'
export default {
  name: 'financing',
  data () {
    return {
    	spinning:false,
    	indicator:<a-icon type="loading-3-quarters"  spin  style="{ fontSize: '16px' }"/> ,
    	delayTime:1000,
    	/*表格栏*/
      	columns:[{
      		  title:'资产名称',
			  dataIndex: 'assetsName',
			  key: 'assetsName', 
			},  {
			  title: '资产规模（万元）',
			  dataIndex: 'assetsSize',  
			}, {
			  title: '资产类型',
			  dataIndex: 'assetsType',
			  scopedSlots: { customRender: 'assetsType' },
			}, {
			  title: '相关公司',
			  dataIndex: 'company',
			}, {
			  title: '发布时间',
			  dataIndex: 'createTime',
			  scopedSlots: { customRender: 'createTime' },
			}, {
			  title: '发布人',
			  dataIndex: 'createUserName',
			},
			{
			  title: '审核状态',
			  dataIndex: 'status',
			  scopedSlots: { customRender: 'status' },
			},  
			{
			  title: '操作',
			  key: 'action',
			  scopedSlots: { customRender: 'action' },
			}],
		/*地产类*/
		data:[],
		
		search:{
			keyWord:'',
			pageNo:1,
			pageSize:10,
			type:'1',
		},
		
		pagination:{
	        total:0,
	        pageSize: 10,//每页中显示10条数据
	        showSizeChanger: true,

	        pageSizeOptions: ["10", "20"],//每页中显示的数据
	        showTotal: total => `共有 ${total} 条数据`,  //分页中显示总的数据
	      },   

		currentType:'1',//当前tab值
		                                                                                           
    }
  },
  created(){
  	this.pageInit()
  },
  methods:{
  	addNew(){ 
  		this.$router.push('/product/add')
  	},
  	async pageInit(){ 
  		this.spinning = true
  		await list_customer_financing(this.search).then((res)=>{
  			if(res.data.flag == true){
  				this.data = res.data.dataList
  				this.pagination.total = res.data.totalRs
  			}
  			this.spinning = false
  		})
  		
  	},
  	 confirmDel(code){
      del_cus_property(code).then((res)=>{
      	if(res.data.flag == true){
      		this.$message.success(res.data.msg)
      		this.pageInit()
      	}
      })
    },
    productChange(val){ 
    	this.search.keyWord = ''
    	this.search.type = val
    	this.search.pageNo = 1
    	this.search.pageSize = 10
    	this.pageInit()
    },
     /*table页数变化*/
    handleTableChange (pagination, filters, sorter) {
        // console.log(pagination);
        this.search.pageNo = pagination.current
        this.search.pageSize =pagination.pageSize
        this.pageInit()
    },
    
    
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.ant-input{width: 200px;}
</style>
